//
//  TabBar.swift
//  CXSwiftDemo
//
//  Created by 潮汐 on 2023/11/28.
//  Copyright © 2023 小潮汐. All rights reserved.
//

import UIKit

class TabBar: UITabBar {

    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */
    
    
    override func layoutSubviews() {
        super.layoutSubviews()//保证父类没问题
//        print(subviews)
        /*
         [<_UIBarBackground: 0x7fb3d8409c10; frame = (0 0; 390 83); userInteractionEnabled = NO; layer = <CALayer: 0x600001416800>>, <UITabBarButton: 0x7fb3d850fca0; frame = (2 1; 74 48); opaque = NO; layer = <CALayer: 0x60000147a120>>, <UITabBarButton: 0x7fb3d841bdc0; frame = (80 1; 74 48); opaque = NO; layer = <CALayer: 0x60000147a560>>, <UITabBarButton: 0x7fb3d84286b0; frame = (158 1; 74 48); opaque = NO; layer = <CALayer: 0x60000147a860>>, <UITabBarButton: 0x7fb3d8429660; frame = (236 1; 74 48); opaque = NO; layer = <CALayer: 0x60000147ab60>>, <UITabBarButton: 0x7fb3d842a610; frame = (314 1; 74 48); opaque = NO; layer = <CALayer: 0x60000147ae60>>]
         */
        /*把tabbar上的button和title向上移一点*/
        for button in subviews where button is UIControl/*满足button是UIControl类型*/ {//过滤掉UIBarBackground，只剩下UITabBarButton
            var frame = button.frame
            frame.origin.y = -2
            button.frame = frame
        }
    }

}
